function msgList(){
	id:"Sys-msgList";
	var storeMain=new Ext.data.Store({
		reader:new Ext.data.JsonReader({
			root:'data',
		    fields: ['content','title','name',{ name : 'update_time', type : 'date', dateFormat : 'timestamp' }]
		}),
		proxy : new Ext.data.HttpProxy({
		    method: 'post',
		    url: Fn.url("Msg/msg?cmd=list")
		}),		
		autoLoad:true  
	});
	
	//复选框
    var checkBox=new Ext.grid.CheckboxSelectionModel({
        singleSelect:false,
        checkOnly: false,
    });
    
    //添加留言的窗口
    var wins=new Ext.Window({
    	closeAction:'hide',
    	title:'添加留言',
    	layout:'fit',
    	modal:true,
    	resizable:false,
    	width:600,
    	height:220,
    	buttons:[{
    		text:"添加",
    		handler:function(){
    			var grid=Ext.getCmp('App-Js-msgList-grid');
    			var content=Ext.get("content");
    			//Fn.log(content);return;
	    		var addMsgForm=Ext.getCmp('App-Js-msgList-window-addMsgForm');
	    		if(addMsgForm.getForm().isValid()){
		    		var data=addMsgForm.getForm().getValues();
		    		//Fn.log(data);
		    		var content=data.content;
		    		var title=data.title;
		    		var name=document.getElementById('sessionName').getAttribute("value");
		    		if(data){
		    			Ext.Ajax.request({
		    				url: Fn.url('Msg/msg?cmd=addMsg'),
		    				method:'post',
		    				params:{
		    					content:content,
		    					title:title,
		    					name:name
		    				},
		    				success:function(response){
		    					var response=Ext.util.JSON.decode(response.responseText);
		    					if(response.success==false){
		    						Ext.Msg.alert("提示","添加失败...");
		    					} else {
		    						Ext.Msg.alert("提示","添加成功!!!");
		    						grid.getStore().load();
		    						Ext.getCmp('content').setValue();
									Ext.getCmp('title').setValue();
		    					}
		    				}
		               })
		    		}
	    		}else{
	    			Ext.Msg.alert("提示信息", "<font color='red'>输入框不能为空</font>"); 
	    		}
    		}
    	}],
    	items:[{
    		id:"App-Js-msgList-window-addMsgForm",
        	xtype:'form',
        	padding:10,
        	items:[{
        		fieldLabel:'主题',
        		id:"title",
        		xtype:'textfield',
        		name:'title',
        		anchor:'98%',
        		labelAlign:'right',
        		allowBlank:false,
        		blankText:"主题不能为空"
        	  },{
        		fieldLabel:'内容',
        		name:'content',
        		id:'content',
        		xtype:'textarea',
        		anchor:'98%',
                height: 100,
        		labelAlign:'right',
        		allowBlank:false,
        		blankText:"内容不能为空"
           }]
        }]
    });
   
    //主面板
	var panel=new Ext.Panel({
		title:'留言列表',
		id:id,
		closable:true,
		//layout:'fit',
		tbar:[{
			text:'<span style="color:red">添加主题</span>',
			handler:function(){
				var addMsgWin=wins.show();
			}
		   },'|',{
			   text:"<span style='color:red'>删除主题</span>",
				 handler:function(){
					 var gridPanel=Ext.getCmp('App-Js-msgList-grid');
					 var rec = gridPanel.getSelectionModel();
					 var selectedRecord=rec.grid.selModel.selections.items;
					 var name=document.getElementById('sessionName').getAttribute("value");
					 if(selectedRecord.length > 0){
							var msgIds = [];
							for(var i=0;i<selectedRecord.length;i++){
								msgIds[i] = selectedRecord[i].json.msg_id;
							}
							if(msgIds){
								Ext.Ajax.request({
									method: 'post',
									url: Fn.url("Msg/msg?cmd=delButton&msgIds="+msgIds+"&userName="+name),
									success:function(data){
										var rec=Ext.util.JSON.decode(data.responseText);
										if(rec.success==false){
											Ext.Msg.alert("提示信息", "<font color='red'>权限不够</font>"); 
										} 
										else {            
											Ext.Msg.alert("提示","删除成功!!!");
											gridPanel.getStore().load();       
	                                    }  
									}
								})
	                       }
					 }
				 }
		   },' | ',{
			xtype:"textfield",
			id:"App-Js-msgList-grid-input",
			width:50,
			emptyText: '作者'
//			listeners:{
//				change:function(textField,newValue,oldValue){
//					var inputFieldValue=newValue;//var inputFieldValue=textField.getValue();
//					var grid=Ext.getCmp("App-Js-msgList-grid");
//  	        		var store=grid.getStore();
//  	             	store.clearFilter(true);
//  	          	    store.filterBy(function(record,id){
//		          	    if(!inputFieldValue){
//		          			 return true;
//		          		}
//		       			if(record.get('name')==inputFieldValue || record.get('content')==inputFieldValue || record.get('title')==inputFieldValue){
//		       				 return true;
//		       			}else{
//		       				 return false;
//		       			}
//  	      	       });
//			   }
//		    }
		},'-',' ',{
			xtype:"textfield",
			emptyText:"回复者",
			id:"App-js-msg-replayField",
			width:50
		},'-',{
			xtype:"datefield",
			width:100,
			emptyText:"开始时间",
			id:"App-Js-msgList-startTime",
			format:"Y/m/d"
		},'-',{
			xtype:'datefield',
			width:100,
			emptyText:"结束时间",
			id:"App-Js-msgList-endTime",
			format:"Y/m/d"
		},'-',{
			text:"查询",
			handler:function(){
				var userName=Ext.getCmp("App-Js-msgList-grid-input").getValue();
				var replayUser=Ext.getCmp("App-js-msg-replayField").getValue();
				var start=Ext.getCmp("App-Js-msgList-startTime").getValue();
				var end=Ext.getCmp("App-Js-msgList-endTime").getValue();
				storeMain.setBaseParam("userName",userName);
				storeMain.setBaseParam("beginTime", start);
				storeMain.setBaseParam("endTime",end);
				storeMain.setBaseParam("replayUser",replayUser);
				storeMain.load();
			}
		},{
			text:"下载",
			handler:function(){
				var userName=Ext.getCmp("App-Js-msgList-grid-input").getValue();
				var replayUser=Ext.getCmp("App-js-msg-replayField").getValue();
				var start=Ext.getCmp("App-Js-msgList-startTime").getValue();
				var end=Ext.getCmp("App-Js-msgList-endTime").getValue();
				Ext.Ajax.request({
					url: Fn.url("Msg/msg?cmd=downloadInfo&userName="+userName+"&replayUser="+replayUser+"&start="+start+"&end="+end),
					method:'get',
					success:function(response){
						var response=Ext.util.JSON.decode(response.responseText);
						window.open(response.fileName);
					}
				})
			}
		}],
	    items:[
          { 
        	 xtype:'grid',
        	 id:"App-Js-msgList-grid",
        	 region:"north",
        	 height:600,
        	 listeners:{          	                       
        		 afterrender:function(t,e){
        			 grid=t;
        			 Ext.fly(t.id).on('click',function(e,t){
            		     //Fn.log(t);
        				 var msgId=t.getAttribute("msgId");
        				 var type=t.getAttribute("unique");	
        				 if(type=="seeAllReplay"){        					
        					 var wins=new Ext.Window({
        						 modal:true,
        						 resizable:false,
        						 width:600,
        						 height:300,
        						 msgId:msgId,
        						 layout:"fit",
        						 title:"查看该主题的所有回复列表",
        						 items:[{
        							 xtype:"grid",
        							 id:"App-Js-view-msgList-seeReplayList",
        				         	 store:new Ext.data.Store({
     				        			reader:new Ext.data.JsonReader({
     				        				root:'data',
     				        			    fields: ['name','content',{ name : 'update_time', type : 'date', dateFormat : 'timestamp' }]
     				        			}),
     				        			proxy : new Ext.data.HttpProxy({
     				        			    method: 'post',
     				        			    url: Fn.url("Msg/msg?cmd=seeReplay&msgId="+msgId)
     				        			}),
     				        			autoLoad:true
     				        	     }),
     				        	     viewConfig:{
     				        	    	 forceFit:true
     				        	     },
        				         	 columns:[
        				              	   {header:'回复者',dataIndex:'name',width:80},
        				              	   {header:'内容',dataIndex:'content',width:300},
        				            	   {header:'时间',dataIndex:'update_time',width:150,align: 'center', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s')},
        				              	   {
        				              		xtype:'actioncolumn',//用来在单元格里渲染一个或多个图标。 每个图标均可自定义点击处理事件。
        				                   	width:50,
        				                   	align:'center',
        				                   	items:[{icon: Fn.img('icon-del.png'),
        				                   		    tooltip: 'Delete',
        				                   	        handler:function(grid, rowIndex, colIndex){
        				                   	        	var rec = grid.getStore().getAt(rowIndex);
        				                   	        	var grid=Ext.getCmp("App-Js-view-msgList-seeReplayList");
        				                   	        	//Fn.log(rec);
        				                   	        	var replayId=rec.id;
        				                   	        	if(replayId){
        				                   	        		Ext.Ajax.request({
        				                   	        			method: 'post',
        				                   	        			url: Fn.url("Msg/msg?cmd=delReplay&replayId="+replayId),
        				                   	        			success:function(data){
        				                   	        				if(data.success==false){
        				                   	        					Ext.Msg.alert("提示信息", "<font color='red'>删除失败</font>"); 
        				                   	        				} 
        				                   	        				else {            
        				                   	        					Ext.Msg.alert("提示","删除成功!!!");
        				                   	        					grid.getStore().load();       
        				                                             }  
        				                   	        			}
        				                   	        		})
        				                   	        	}
        				                   	        }	    
        				                   	}]   
        				              	   }
        				             ]
        					   }]
        					 }).show();
        				 }else{
        					 var wins=new Ext.Window({
        						 width:700,
        						 height:300,
        						 msgId:msgId,
        						 title:"回复该主题",
        						 buttons:[{
        							 text:"回复",
        							 handler:function(){
        								var replayForm=Ext.getCmp("App-Js-msgList-replayMsg-window-form");
        								if(replayForm.getForm().isValid()){
	        								var data=replayForm.getForm().getValues();
	        								var content=data.content;
	        								if(data){
	        					    			Ext.Ajax.request({
	        					    				url: Fn.url('Msg/msg?cmd=replayMsg'),
	        					    				method:'post',
	        					    				params:{
	        					    					content:content,
	        					    					msgId:msgId
	        					    				},
	        					    				success:function(response){
	        					    					var response=Ext.util.JSON.decode(response.responseText);
	        					    					if(response.success==false){
	        					    						Ext.Msg.alert("提示","回复失败...");
	        					    					} else {
	        					    						Ext.Msg.alert("提示","回复成功!!!");
	        					    						grid.getStore().load();
	        					    						wins.close();
	        					    					}
	        					    				}
	        					               })
	        					    		}
        								}else{
        									Ext.Msg.alert("提示信息", "<font color='red'>输入框不能为空</font>"); 
        								}
        							 }
        						 }],
        						 items:[{
        							 xtype:"form",
        							 id:"App-Js-msgList-replayMsg-window-form",
        							 items:[{
        								 fieldLabel:"回复该主题",
        								 name:'content',
            							 xtype:'textarea',
            							 anchor:'97%',
            							 height: 200,
            							 allowBlank:false,
            							 blankText:"内容不能为空"
            						
        							 }]
        						 }]
        					 }).show();
        				 }
        		    },null,{delegate:"span[type='msg']"}); 
        		 },
        		 cellclick:function(grid,rowIndex,columnIndex,e ){
        			var rel=grid.getStore().getAt(rowIndex);
        			var msgId=rel.json.msg_id;
        			var sourthPanel=Ext.getCmp("index_center_south");
        			sourthPanel.load({//注意在extjs4.0里是要在对应的panel下加一个loader：{}属性，然后这里就是sourthPanel.getLoader().load({url:Fn.url(
        				url:Fn.url('Msg/info'),
        				params:{msgId:msgId}
        			}); 
     			 }
        	 },
        	 viewConfig : {
        		//True表示为自动展开/缩小列的宽度以适应grid的宽度，这样就不会出现水平的滚动条
        		 forceFit : true
        	 },	
        	 bbar: new Ext.PagingToolbar({
        		 store:storeMain,   
        		 displayInfo: true,
        		 pageSize: 20, 
        		 prependButtons: true,
        		 displayMsg: '显示 {0} - {1} / 共 {2} 条'
        	 }),
        	 selModel:checkBox,
        	 columns:[
               checkBox,
        	   {header:'主题',dataIndex:'title',width: 50},
        	   {header:'内容',dataIndex:'content',width:200},
        	   {header:'作者',dataIndex:'name',width: 30},
        	   {header:'时间',dataIndex:'update_time',align: 'center', renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s')},
        	   {
        		header:"查看所有回复",dataIndex:'allReplay',align:'center',width:120,renderer:function(val,cel,record,rowIndex){
        			var msgId=record.json.msg_id;
        			return'<span  style="cursor:pointer;color:blue;text-decoration:underline;" type="msg" unique="seeAllReplay" msgId="'+msgId+'">查看所有回复</span>'
        			+ "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
        			'<span  style="cursor:pointer;color:blue;text-decoration:underline;"  type="msg"  unique="replay" msgId="'+msgId+'">回复</span>';
        		}
        	   },{
              	xtype:'actioncolumn',//用来在单元格里渲染一个或多个图标。 每个图标均可自定义点击处理事件。
              	width:50,
              	align:'center',
              	items:[{icon: Fn.img('icon-del.png'),
              		    tooltip: 'Delete',
              	        handler:function(grid, rowIndex, colIndex){
              	        	var rec = grid.getStore().getAt(rowIndex);
              	        	//Fn.log(rec);
              	        	var msgId=rec.json.msg_id;
              	        	var name=document.getElementById('sessionName').getAttribute("value");
              	        	if(msgId){
              	        		Ext.Ajax.request({
              	        			method: 'post',
              	        			url: Fn.url("Msg/msg?cmd=delMsg&msgId="+msgId+"&userName="+name),
              	        			success:function(data){
              	        				var rec=Ext.util.JSON.decode(data.responseText);
              	        				if(rec.success==false){
              	        					Ext.Msg.alert("提示信息", "<font color='red'>权限不够</font>"); 
              	        				} 
              	        				else {            
              	        					Ext.Msg.alert("提示","删除成功!!!");
              	        					grid.getStore().load();       
                                        }  
              	        			}
              	        		})
              	        	}
              	        }	    
              	}]
               }
        	 ],
        	 store:storeMain
        },{
        	 xtype:"panel",
    		 id:"index_center_south",
	 		 region:"south",
	 		 title:'主题信息详情',
	 		 height:300,
	 		 collapsible:true,
	 		 tbar:[
	 		   '->',    
	 		   {text:'保存',handler:function(){
	 			   var id=document.getElementById("content_msg_id").getAttribute("value");
	 			   var title=document.getElementById("content_msg_title").value;//得到表单输入的值
	 			   var content=document.getElementById("content_msg_content").value;
	 			   var grid=Ext.getCmp("App-Js-msgList-grid");
	 			   if(id){
    	        		Ext.Ajax.request({
    	        			method: 'post',
    	        			url:Fn.url("Msg/msg?cmd=update"),
    	        			params:{
    	        				id:id,
    			    			content:content,
    			    			title:title
    			    		},
    	        			success:function(data){
    	        				if(data.success==false){
    	        					Ext.Msg.alert("提示信息", "<font color='red'>保存失败</font>"); 
    	        				} 
    	        				else {            
    	        					Ext.Msg.alert("提示","保存成功!!!");
    	        					grid.getStore().load();       
                              }  
    	        			}
    	        		})
    	        	}
	 			   
	 		   }}      
	 		 ]
        }]
	});
	this.panel=panel;
}